#-*-encoding=utf-8-*-
@script_attr(permission='zope.View', use_template=True)
def index():
    """首页

None"""

    from random import randint
    
    a = request.get('a', 0)
    b = request.get('b', 0)
    result = request.get('result',0)
    
    info = '欢迎开始加法练习...'
    if result:
        if result == a +b:
            info = '<b>恭喜，您答对了，继续享受快乐答题吧！</b>'
        else:
            info = '<b>答错了，答案我也不告诉你，继续答题吧... </b>'
    
    a = randint(0,100)
    b = randint(0,100)
    
    return '''<form><h1>加法练习</h1>%s<br/>
     <input name="a:int" value="%d" /> + 
     <input name="b:int" value="%d" /> = 
     <input name="result:int" value="0" /> <input type="submit" value="查看答案！"/> </form>''' % (info, a,b)

